home *** CD-ROM | disk | FTP | other *** search
/ 130 MIDI Tool Box / 130 MIDI Tool Box.iso / mpu401 / mpuid.c < prev    next >
C/C++ Source or Header  |  1986-11-02  |  1KB  |  52 lines

  1. /* Copyright (C) 1986 by M. J. Shannon, Jr.
  2. ** Permission to distribute for non-commercial uses granted as long as this
  3. ** notice is retained.  Violators will be prosecuted.
  4. */
  5.  
  6. #include    "mpu.h"
  7.  
  8. /* mpu_id():
  9. **    obtains the version & revision numbers of the MPU firmware and formats
  10. **    it into a string suitable for printing.  The address of the (static)
  11. **    string is returned.
  12. */
  13.  
  14. char *
  15. mpu_id()
  16. {
  17.     static char vers_string[9];
  18.     register int v, r;
  19.     register char *p = &vers_string[0];
  20.  
  21.     v = mpu_get(GET_VERSION);
  22.     r = (v >> 4) & 0x0F;
  23.     if (r > 9)
  24.         *p++ = '1', r -= 10;
  25.     *p++ = r + '0';
  26.     *p++ = '.';
  27.     v &= 0x0F;
  28.     if (v > 9)
  29.         *p++ = '1', v -= 10;
  30.     *p++ = v + '0';
  31.     r = mpu_get(GET_REVISION);
  32.     if (r)
  33.     {
  34.         if (r > 0)
  35.         {
  36.             if (r > 26)
  37.             {
  38.                 *p++ = 'r';
  39.                 v = r / 100;
  40.                 if (v) *p++ = v + '0', r -= v * 100;
  41.                 v = r / 10;
  42.                 if (v) *p++ = v + '0', r -= v * 10;
  43.                 if (r) *p++ = r + '0';
  44.             }
  45.             else
  46.                 *p++ = r + '@';
  47.         }
  48.     }
  49.     *p = '\0';
  50.     return (vers_string);
  51. }
  52.